home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Letterspacing.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.4 KB  |  96 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. void LetterSpacing(WindowPtr sampleWindow)
  36.     {
  37.     /* Variables */
  38.     char        *myString = "AAABBBBAAA";
  39.     gxPoint        myPoint;
  40.     gxRunControls    gxRunControls;
  41.     gxShape        layout;
  42.     short        len, level = 0, runLengths[3];
  43.     gxStyle        regularStyle, tweakedStyle, styleArray[3];
  44.     gxViewPort    aViewPort;
  45.     
  46.     /* Initialization */
  47.     
  48.     myPoint.x = ff(30);
  49.     myPoint.y = ff(50);
  50.     
  51.     /* Standard opening game */
  52.     
  53.     aViewPort = GXNewWindowViewPort(sampleWindow);
  54.     SetDefaultViewPort(aViewPort);
  55.     
  56.     len = MyStrLen(myString);
  57.     runLengths[0] = runLengths[2] = 3;
  58.     runLengths[1] = 4;
  59.     
  60.     regularStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  61.     tweakedStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  62.     
  63.     styleArray[0] = styleArray[2] = regularStyle;
  64.     styleArray[1] = tweakedStyle;
  65.     
  66.     layout = GXNewLayout(
  67.         1, &len, (void *) &myString,
  68.         3, runLengths, styleArray,
  69.         1, &len, &level,
  70.         nil, &myPoint);
  71.     GXDrawShape(layout);
  72.     
  73.     InitializeRunControls(&gxRunControls);
  74.     gxRunControls.beforeWithStreamShift = ff(10);
  75.     GXSetStyleRunControls(tweakedStyle, &gxRunControls);
  76.     GXMoveShape(layout, 0, ff(100));
  77.     GXDrawShape(layout);
  78.     
  79.     gxRunControls.beforeWithStreamShift = 0;
  80.     gxRunControls.afterWithStreamShift = ff(10);
  81.     GXSetStyleRunControls(tweakedStyle, &gxRunControls);
  82.     GXMoveShape(layout, 0, ff(100));
  83.     GXDrawShape(layout);
  84.     
  85.     gxRunControls.afterWithStreamShift = 0;
  86.     gxRunControls.crossStreamShift = ff(10);
  87.     GXSetStyleRunControls(tweakedStyle, &gxRunControls);
  88.     GXMoveShape(layout, 0, ff(100));
  89.     GXDrawShape(layout);
  90.  
  91.     GXDisposeShape(layout);
  92.     GXDisposeStyle(regularStyle);
  93.     GXDisposeStyle(tweakedStyle);
  94.     GXDisposeViewPort(aViewPort);
  95.     }    /* main */
  96.